import axios from 'axios'


const BASE_URL = "/api";
//通过create方法创建一个Axios实例
const Server = axios.create({
    baseURL: BASE_URL,
    timeout: 10000
})
Server.defaults.headers.post["Content-Type"] = "application/json;charset=utf-8";
Server.interceptors.request.use(config => {
    if (localStorage.getItem("token")) {
        config.headers['token'] = localStorage.getItem("token");
    }
    console.log("loading显示");
    return config
}, err => {
    return Promise.reject(err);
})

Server.interceptors.response.use(config => {
    return config;
}, err => {
    return Promise.reject(err);
})

export default Server;